//post请求
const axiosPostRequst = (url, data) => {
  let result = axios({
    method: 'post',
    url: "https://10.248.70.86/api" + url,
    data
  }).then(res => {
    return res.data;
  }).catch(err => {
    return "exception=" + err;
  });
  return result;
}
// get请求
const axiosGetRequst = (url, params) => {
  let result = axios({
    method: 'get',
    url: "https://10.248.70.86/api" + url,
    params
  }).then((res) => {
    return res.data;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}
// let str = window.location.origin + "/" ; // 生产和测试
let str = "http://10.247.85.232/" // 本地开发
//2.1
const postOneId = (url, data) => {
  let result = axios({
    method: 'post',
    url: str + "mobile/operFlowZb/" + url,
    params: data
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}
//2.1下载
const getOneIdDownload = (url, data) => {
  let result = axios({
    method: 'get',
    url: str + "mobile/operFlowZb/" + url,
    params: data,
    responseType: 'blob',
    headers: { 'Content-Type': "application/octet-stream" }
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}
//2.2
const postTwoId = (url, data) => {
  let result = axios({
    method: 'post',
    url: str + "mobile/operFlowQy/" + url,
    params: data
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}
//2.3
const postThreeId = (url, data) => {
  let result = axios({
    method: 'post',
    url: str + "mobile/flowZb/" + url,
    params: data
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}
//2.3下载
const getThreeIdDownload = (url, data) => {
  let result = axios({
    method: 'get',
    url: str + "mobile/flowZb/" + url,
    params: data,
    responseType: 'blob',
    headers: { 'Content-Type': "application/octet-stream" }
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}
// 2.5
const postFiveId = (url, data) => {
  let result = axios({
    method: 'post',
    url: str + "mobile/dataReportZb/" + url,
    params: data
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}
// 2.5下载
const getFiveIdDownload = (url, data) => {
  let result = axios({
    method: 'get',
    url: str + "mobile/dataReportZb/" + url,
    params: data,
    responseType: 'blob',
    headers: { 'Content-Type': "application/octet-stream" }
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}
// App
const postAppId = (url, data) => {
  let result = axios({
    method: 'post',
    url: str + "mobile/appStatistics/" + url,
    params: data
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}
//app下载
const getAppDownload = (url, data) => {
  let result = axios({
    method: 'get',
    url: str + "mobile/appStatistics/" + url,
    params: data,
    responseType: 'blob',
    headers: { 'Content-Type': "application/octet-stream" }
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}
//4
const postFourRequest = (url, data) => {
  let result = axios({
    method: 'post',
    url: str + "mobile/userBehavior/" + url,
    params: data
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}

//权限接口企业
const RequestJurisdiction = (data) => {
  let result = axios({
    method: 'post',
    url: str + "mobile/public/tokenCheck",
    params: data
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}
// 检验总部接口权限
const checkAllAuth = (data) => {
  let result = axios({
    method: 'post',
    url: str + "mobile/public/tokenCheckAll",
    params: data
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}
//权限接口总部
const RequestJurisdictionAll = (data) => {
  let result = axios({
    method: 'post',
    url: str + "mobile/public/yhqx00_all",
    params: data
  }).then(res => {
    return res;
  }).catch((err) => {
    return "exception=" + err;
  });
  return result;
}

export {
  axiosPostRequst,
  axiosGetRequst,
  postOneId,
  getOneIdDownload,
  postTwoId,
  postThreeId,
  getThreeIdDownload,
  postFiveId,
  getFiveIdDownload,
  postAppId,
  postFourRequest,
  getAppDownload,
  RequestJurisdiction,
  RequestJurisdictionAll,
  checkAllAuth
}